package com.freewater.javabase.demo.designpattern.state;

/**
 * 准备状态，有充值的糖果，等待投币
 */
public class OnReadyState implements State{

    private CandyMachine candyMachine;

    public OnReadyState(CandyMachine candyMachine) {
        this.candyMachine = candyMachine;
    }

    @Override
    public void insertCoin() {
        System.out.println("you have inserted a coin, next, please turn crank!");
        this.candyMachine.setState(candyMachine.hasCoinState);
    }

    @Override
    public void returnCoin() {
        System.out.println("you haven't inserted a coin yet!");
    }

    @Override
    public void turnCrank() {
        System.out.println("you turned, but you haven't inserted a coin!");
    }

    @Override
    public void dispense() {
        // do nothing
    }

    @Override
    public void printState() {
        System.out.println("***OnReadyState***");
    }
}
